<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>FEUP-Defender: Queue</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Gerado por Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Página&nbsp;principal</span></a></li>
      <li><a href="modules.html"><span>Módulos</span></a></li>
      <li><a href="annotated.html"><span>Estruturas&nbsp;de&nbsp;dados</span></a></li>
      <li><a href="files.html"><span>Ficheiros</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>Queue</h1><table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Estruturas de Dados</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_queue.html">Queue</a></td></tr>
<tr><td colspan="2"><h2>Funções</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__queue.html#ga92674b703b54d19714e58b4521e960d9">queueInit</a> (<a class="el" href="struct_queue.html">Queue</a> *q)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___user_types.html#ga39db6982619d623273fad8a383489309">Bool</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__queue.html#ga82898e23d9973c2d48b32719073c1f3f">queuePut</a> (<a class="el" href="struct_queue.html">Queue</a> *q, <a class="el" href="group___user_types.html#gae3a497195d617519e5353ea7b417940f">Byte</a> c)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__queue.html#gac74285636b6e45f870e193cd790ed5a5">queueGet</a> (<a class="el" href="struct_queue.html">Queue</a> *q)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga6d2f67a6af38934d09aef6b609109179"></a><!-- doxytag: member="queue::queueClear" ref="ga6d2f67a6af38934d09aef6b609109179" args="(Queue *q)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><b>queueClear</b> (<a class="el" href="struct_queue.html">Queue</a> *q)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___user_types.html#ga39db6982619d623273fad8a383489309">Bool</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__queue.html#ga80d4134ca16818ec36c96799d474013a">queueEmpty</a> (<a class="el" href="struct_queue.html">Queue</a> *q)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___user_types.html#ga39db6982619d623273fad8a383489309">Bool</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__queue.html#gaf052cf742bfd58dee32a98757a049bb5">queueFull</a> (<a class="el" href="struct_queue.html">Queue</a> *q)</td></tr>
<tr><td colspan="2"><h2>Variáveis</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga26aeebe75887b4360c73659342f5dc61"></a><!-- doxytag: member="queue::in" ref="ga26aeebe75887b4360c73659342f5dc61" args="" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><b>in</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaa8000eda101cade7c6c4b913fce0cc9c"></a><!-- doxytag: member="queue::out" ref="gaa8000eda101cade7c6c4b913fce0cc9c" args="" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><b>out</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga9cfbb269728dc4185236d28be58d9eab"></a><!-- doxytag: member="queue::cnt" ref="ga9cfbb269728dc4185236d28be58d9eab" args="" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><b>cnt</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga5984ab6711f54b9b555bd934424244a7"></a><!-- doxytag: member="queue::being_accessed" ref="ga5984ab6711f54b9b555bd934424244a7" args="" -->
<a class="el" href="group___user_types.html#ga39db6982619d623273fad8a383489309">Bool</a>&nbsp;</td><td class="memItemRight" valign="bottom"><b>being_accessed</b></td></tr>
</table>
<hr/><a name="_details"></a><h2>Descrição detalhada</h2>
<p><a class="el" href="struct_queue.html">Queue</a> related functions </p>
<hr/><h2>Documentação das funções</h2>
<a class="anchor" id="ga80d4134ca16818ec36c96799d474013a"></a><!-- doxytag: member="QUEUE.H::queueEmpty" ref="ga80d4134ca16818ec36c96799d474013a" args="(Queue *q)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group___user_types.html#ga39db6982619d623273fad8a383489309">Bool</a> queueEmpty </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_queue.html">Queue</a> *&nbsp;</td>
          <td class="paramname"> <em>q</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns true if the queue is empty </p>

<p>Definido na linha <a class="el" href="#L40">40</a> do ficheiro <a class="el" href="">QUEUE.C</a>.</p>

<p><div class="fragment"><pre class="fragment"><a name="l00041"></a>00041 {
<a name="l00042"></a>00042         <span class="keywordflow">return</span> (q-&gt;cnt == 0);
<a name="l00043"></a>00043 }
</pre></div></p>

</div>
</div>
<a class="anchor" id="gaf052cf742bfd58dee32a98757a049bb5"></a><!-- doxytag: member="QUEUE.H::queueFull" ref="gaf052cf742bfd58dee32a98757a049bb5" args="(Queue *q)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group___user_types.html#ga39db6982619d623273fad8a383489309">Bool</a> queueFull </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_queue.html">Queue</a> *&nbsp;</td>
          <td class="paramname"> <em>q</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns true if the queue if full </p>

<p>Definido na linha <a class="el" href="#L46">46</a> do ficheiro <a class="el" href="">QUEUE.C</a>.</p>

<p><div class="fragment"><pre class="fragment"><a name="l00047"></a>00047 {
<a name="l00048"></a>00048         <span class="keywordflow">return</span> (q-&gt;cnt == QUEUE_MAX_SIZE);
<a name="l00049"></a>00049 }
</pre></div></p>

</div>
</div>
<a class="anchor" id="gac74285636b6e45f870e193cd790ed5a5"></a><!-- doxytag: member="QUEUE.H::queueGet" ref="gac74285636b6e45f870e193cd790ed5a5" args="(Queue *q)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int queueGet </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_queue.html">Queue</a> *&nbsp;</td>
          <td class="paramname"> <em>q</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Get next element from queue Returns -1 (an int) if there are no elements in the queue </p>

<p>Definido na linha <a class="el" href="#L25">25</a> do ficheiro <a class="el" href="">QUEUE.C</a>.</p>

<p><div class="fragment"><pre class="fragment"><a name="l00026"></a>00026 {
<a name="l00027"></a>00027         <span class="keywordflow">if</span>(q-&gt;being_accessed) <span class="keywordflow">return</span> -1;
<a name="l00028"></a>00028         <span class="keywordflow">if</span>(q-&gt;cnt == 0) <span class="keywordflow">return</span> -1;
<a name="l00029"></a>00029         
<a name="l00030"></a>00030         q-&gt;being_accessed = <span class="keyword">true</span>;
<a name="l00031"></a>00031         <a class="code" href="group___user_types.html#gae3a497195d617519e5353ea7b417940f" title="8 bits, only on i386">Byte</a> data = (q-&gt;buf)[q-&gt;out];
<a name="l00032"></a>00032         q-&gt;cnt--; q-&gt;out++;
<a name="l00033"></a>00033         <span class="keywordflow">if</span>(q-&gt;out == QUEUE_MAX_SIZE) q-&gt;out = 0;
<a name="l00034"></a>00034         q-&gt;being_accessed = <span class="keyword">false</span>;
<a name="l00035"></a>00035         
<a name="l00036"></a>00036         <span class="keywordflow">return</span> data;
<a name="l00037"></a>00037 }
</pre></div></p>

</div>
</div>
<a class="anchor" id="ga92674b703b54d19714e58b4521e960d9"></a><!-- doxytag: member="QUEUE.H::queueInit" ref="ga92674b703b54d19714e58b4521e960d9" args="(Queue *q)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void queueInit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_queue.html">Queue</a> *&nbsp;</td>
          <td class="paramname"> <em>q</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Initialize the queue </p>

<p>Definido na linha <a class="el" href="#L3">3</a> do ficheiro <a class="el" href="">QUEUE.C</a>.</p>

<p><div class="fragment"><pre class="fragment"><a name="l00004"></a>00004 {
<a name="l00005"></a>00005         q-&gt;in = q-&gt;out = q-&gt;cnt = 0;
<a name="l00006"></a>00006         q-&gt;being_accessed = <span class="keyword">false</span>;
<a name="l00007"></a>00007 }
</pre></div></p>

</div>
</div>
<a class="anchor" id="ga82898e23d9973c2d48b32719073c1f3f"></a><!-- doxytag: member="QUEUE.H::queuePut" ref="ga82898e23d9973c2d48b32719073c1f3f" args="(Queue *q, Byte c)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group___user_types.html#ga39db6982619d623273fad8a383489309">Bool</a> queuePut </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_queue.html">Queue</a> *&nbsp;</td>
          <td class="paramname"> <em>q</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group___user_types.html#gae3a497195d617519e5353ea7b417940f">Byte</a>&nbsp;</td>
          <td class="paramname"> <em>c</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Put char 'c' in the queue pointed to by 'q' Returns false if operation failed (the queue is full) </p>

<p>Definido na linha <a class="el" href="#L10">10</a> do ficheiro <a class="el" href="">QUEUE.C</a>.</p>

<p><div class="fragment"><pre class="fragment"><a name="l00011"></a>00011 {
<a name="l00012"></a>00012         <span class="keywordflow">if</span>(q-&gt;being_accessed) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00013"></a>00013         <span class="keywordflow">if</span>(q-&gt;cnt == QUEUE_MAX_SIZE) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00014"></a>00014         
<a name="l00015"></a>00015         q-&gt;being_accessed = <span class="keyword">true</span>;
<a name="l00016"></a>00016         (q-&gt;buf)[q-&gt;in] = elem;
<a name="l00017"></a>00017         q-&gt;cnt++; q-&gt;in++;
<a name="l00018"></a>00018         <span class="keywordflow">if</span>(q-&gt;in == QUEUE_MAX_SIZE) q-&gt;in = 0;
<a name="l00019"></a>00019         q-&gt;being_accessed = <span class="keyword">false</span>;
<a name="l00020"></a>00020         
<a name="l00021"></a>00021         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00022"></a>00022 }
</pre></div></p>

</div>
</div>
</div>
<hr class="footer"/><address style="text-align: right;"><small>Gerado em Tue Jun 1 22:04:48 2010 para FEUP-Defender por&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
